﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Sunboxsoft.WinForm;
using WebRef = Sunboxsoft.ASMS.Client.Domain.WebRef;
using Service = Sunboxsoft.ASMS.Client.Domain.Service;
using Sunboxsoft.Common;
using Sunboxsoft.ASMS.Client.UI.Properties;
namespace Sunboxsoft.ASMS.Client.UI.Show
{
    /// <summary>
    /// 查看库存预警值
    /// </summary>
    public partial class ShowStockWarningView : UserControl, IView
    {
        WebRef.VStockThresholdValue itemStockThresholdValue = null;
        Promise _promise = new Promise();
        public ShowStockWarningView()
        {
            InitializeComponent();
        }
        public ShowStockWarningView(WebRef.VStockThresholdValue itemStockThresholdValue)
            : this()
        {
            this.itemStockThresholdValue = itemStockThresholdValue;
        }

        #region IView 成员

        public ViewHeader GetHeader()
        {
            return new ViewHeader("查看库存预警值");
        }
        public void RegisterAction(ActionNodeCollection collection)
        {
            collection
              .AddAction(new ActionNode("close", Resources.isDelete, "关闭", OnCloseClick));
        }
        public void Active(ViewActiveArgs args)
        {
            _promise.Then(() =>
            {
                this.BeginInvoke(new Action(() =>
                {
                    if (this.itemStockThresholdValue != null)
                    {
                        this.ctlEditWareHouse.Text = itemStockThresholdValue.WarehouseName;
                        this.ctlEditMaterial.Text = itemStockThresholdValue.MaterialName;
                        this.ctlEditWarmingNum.EditValue = itemStockThresholdValue.Value;
                    }
                    _promise.Resolve();
                }));
            }).Run();
        }
        public void Resume(ViewResumeArgs args)
        {
        }
        #endregion

        #region Action
        /// <summary>
        /// 关闭
        /// </summary>
        private void OnCloseClick(object sender, object e)
        {
            UIContext.Current.ViewManager.CloseView(false, null);
        }
        #endregion
    }
}
